function add_receiver()
{
	var friendsList = $("#friends")[0];
	
	for( var i = 0; i < friendsList.options.length; i++ )
	{
		
		if( friendsList.options[i].selected == true )
		{
						
			var fname = friendsList.options[i].text.trim();
			
			var receiver = $("#receivers")[0].value.trim();
			
			var reg1 = new RegExp( "^" + fname + "$", "g" );
			var reg2 = new RegExp( "^" + fname + ";", "g" );
			var reg3 = new RegExp( ";" + fname + "$", "g" );
			var reg4 = new RegExp( ";" + fname + ";", "g" );
			
			if( !reg1.exec(receiver) &&
				!reg2.exec(receiver) &&
				!reg3.exec(receiver) &&
				!reg4.exec(receiver) )
			{
				if( receiver.charAt( receiver.length - 1) == ';' ||
					receiver.length == 0 )
					$("#receivers").val( receiver + fname + ";");
				else
					$("#receivers").val( receiver + ";" + fname + ";");
			}
			
		}
	}
}

function send_mail()
{
	var friendsList = $("#friends")[0];
	var receivers = ";" + $("#receivers")[0].value.trim(); 
	var id_list = "";
	for( var i = 0; i< friendsList.options.length; i++ )
	{
		var fname = friendsList.options[i].text.trim();
		var reg = new RegExp( ";" + fname + ";" );
		if( reg.exec(receivers) )
			id_list += friendsList.options[i].value + ","
	}
	
	if( id_list == "" )
	{
		alert( "必须选择有效的收件人！");
		return false;
	}
	
	$("#ids").val( id_list );
	
	return true;	
}